package com.example.patentback.service.impl;

import com.example.patentback.dao.HelperMapper;
import com.example.patentback.entity.Helper;
import com.example.patentback.entity.Patent;
import com.example.patentback.service.HelperService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;

@Service
public class HelperServiceImpl implements HelperService {

    @Autowired
    HelperMapper helperMapper;

    @Override
    public List<Helper> selectHelpers(int start) {
        int pageSize = 5;
        int index = (start - 1) * pageSize;
        RowBounds rowBounds = new RowBounds(index, pageSize);
        List<Helper> helpers = helperMapper.selectByRowBounds(new Helper(),rowBounds);
        return helpers;
    }

    @Override
    public List<Helper> selectHelpersById(Long id) {
        Example example = new Example(Helper.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("id",id);
        return helperMapper.selectByExample(example);
    }
}
